package com.fan.controller;

import com.fan.service.*;
import com.sixth.entity.Course;
import com.sixth.entity.EduTeacher;
import com.sixth.entity.Order;
import com.sixth.entity.TbMember;
import com.sixth.until.CommonResult;
import com.sixth.until.TableResult;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: self-tui-education
 * @description:
 * @author: 老范
 * @create: 2022-04-16 13:04
 **/
@RestController
@RequestMapping("/order")
public class OrderListController {
    @Autowired
    private OrderListService orderListService;
    @Autowired
    private CourseService courseService;
    @Autowired
    private MemberService memberService;
    @Autowired
    private PayLogService payLogService;
    @Autowired
    private TeacherService teacherService;


    @PostMapping("order/getAllOrder/{currentPage}/{pageSize}")
    public TableResult getAllOrder(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody Order order){
//        Order order = new Order();
//        order.setOrderNo("c60801fbdd2d45f9ad4");
       //System.out.println("进来了");
        return orderListService.findOrderList(currentPage,pageSize,order);

    }

    //查询课程信息
    @PostMapping("/course/queryAllCourse/{courseId}")
    public List<Course> queryAllCourse(@PathVariable String courseId){
//        System.out.println("来了");
//        System.out.println(courseId);
        return courseService.findCourseId(courseId);
    }

    //查询用户信息
    @PostMapping("member/queryAllMemberById/{memberId}")
    public TbMember queryAllMemberById(@PathVariable String memberId){
        //System.out.println(111111);
        //System.out.println(memberId);
        return memberService.findMemberId(memberId);
    }


    //查询订单详情
    @PostMapping("order/queryOrderAndPayLog/{id}")
    public CommonResult queryOrderAndPayLog(@PathVariable String id){
        System.out.println(id);
        return payLogService.queryOrderAndPayLog(id);
    }

//    //查询讲师信息
//    @PostMapping("teacher/queryAllTeacherBYTeacherName/{teacherName}")
//    public EduTeacher queryAllTeacherBYTeacherName(@PathVariable String teacherName){
//        //System.out.println("222222");
//        //System.out.println(teacherName);
//        return teacherService.findTeacherName(teacherName);
//    }

    //获取当前教师的信息
    @GetMapping("/teacher/findTeacherBYMobile/{teacherMobile}")
    public CommonResult findTeacherBYMobile(@PathVariable String teacherMobile){
        return teacherService.findTeacherBYMobile(teacherMobile);
    }
}
